#!/bin/bash
# DATE: 2021-01-08 14:42:09
# FileName:     ansible_install.sh
# Description:  NULL
# Depend:       get_sys.sh
#

##################################加载依赖##################################
Load_dependencies()
{
    local i depend var_tmp
    # 依赖 每行一个
    depend=(
        get_sys.sh
    )
    depend_url=https://gitee.com/uon/conf/raw/master/
    for i in "${depend[@]}";do
        var_tmp=$(echo $i|cut -c 1-$((${#i}-3)))
        if [[ ! $(type -t $var_tmp) == "function" ]];then
            
            if [ -f "$i" ];then
                if source "${i}";then
                    echo -e "\e[1;32mSuccessfully loaded ${i}\e[0m"
                else
                    echo -e "\e[1;31mFailed to load ${i}\e[0m"
                fi
            else
                if source <(curl -sLk "${depend_url}${i}");then
                    echo -e "\e[1;32mSuccessfully loaded ${i}\e[0m"
                else
                    echo -e "\e[1;31mFailed to load ${i}\e[0m"
                fi
            fi
        fi
    done
}
Load_dependencies
############################################################################


ansible_install()
{
    if ! which axel ;then
        if [ "$(get_sys)" == "Ubuntu" ];then
            apt install -y ansible
            elif [ "$(get_sys)" == "CentOS" ];then
            yum install -y ansible
            
        fi
    fi
    
}



